package promotion

import (
	// "bp/cache"
	sqlc "bp/db/sqlc"
	"bp/internal/util"
)

func (s *PromotionEntityServiceImp) ConvToPromotionIDs(i interface{}) []int64 {
	return util.MapToInt64(util.ToGenericSlice(i), func(v interface{}) int64 {
		switch t := v.(type) {
		case *sqlc.Promotion:
			return t.ID
		case *sqlc.ListPromotionWithStatsRow:
			return t.ID
		}
		return 0
	})
}

func (s *PromotionEntityServiceImp) MapPromotionEntityToPtr(list []sqlc.Promotion) []*sqlc.Promotion {
	ptrs := make([]*sqlc.Promotion, len(list))
	for i := range list {
		ptrs[i] = &list[i]
	}
	return ptrs
}

func (s *PromotionEntityServiceImp) MapPromotionWithStatEntityToPtr(list []sqlc.ListPromotionWithStatsRow) []*sqlc.ListPromotionWithStatsRow {
	ptrs := make([]*sqlc.ListPromotionWithStatsRow, len(list))
	for i := range list {
		ptrs[i] = &list[i]
	}
	return ptrs
}